package net.hn.hnms.biz.support.company.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.hn.hnms.biz.support.company.domain.dto.RiskStatisticsDto;
import net.hn.hnms.biz.support.company.domain.vo.ChartVo;
import net.hn.hnms.biz.support.company.domain.vo.NowDetectionVo;
import net.hn.hnms.biz.support.company.domain.vo.ScoreRankingVo;
import net.hn.hnms.biz.support.company.domain.vo.TodayAlarmVo;
import net.hn.hnms.biz.support.service.RoofHazardService;
import net.hn.hnms.sys.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;


/**
 * 华能集团-安全管理-顶板灾害
 */
@Api(value = "华能集团-安全管理-顶板灾害", tags = {"公司端-顶板灾害"})
@RestController
@RequestMapping("company/roofHazard")
public class RoofHazardController {

    @Autowired
    private RoofHazardService roofHazardService;
    @ApiOperation("实时检测")
    @GetMapping("nowDetection")
    public R<NowDetectionVo> nowDetection(@ApiParam(value = "煤矿编码") String mineCode,@ApiParam(value = "公司编码") String companyCode) {
        NowDetectionVo nowDetectionVo = roofHazardService.nowDetection();
        return R.ok(nowDetectionVo);
    }

    @ApiIgnore
    @ApiOperation("联网情况")
    @GetMapping("networking")
    public R networking(@ApiParam(value = "煤矿编码") String mineCode,@ApiParam(value = "公司编码") String companyCode) {
        return R.ok();
    }


    @ApiOperation("今日报警处置情况")
    @GetMapping("todayAlarm")
    public R<List<TodayAlarmVo>> todayAlarm(@ApiParam(value = "煤矿编码") String mineCode,@ApiParam(value = "公司编码") String companyCode) {
        List<TodayAlarmVo> list=roofHazardService.todayAlarm();
        return R.ok(list);
    }

    @ApiOperation("顶板灾害安全评分排名")
    @GetMapping("safetyScore")
    public R<List<ScoreRankingVo>> safetyScore(@ApiParam(value = "煤矿编码") String mineCode,@ApiParam(value = "公司编码") String companyCode) {
        List<ScoreRankingVo> scoreRankingVoList = new ArrayList<>();
        ScoreRankingVo scoreRankingVo = new ScoreRankingVo();
        scoreRankingVo.setScore(new BigDecimal("96.6"));
        scoreRankingVo.setCompany("北能公司");
        scoreRankingVo.setMine("高头窑煤矿");
        scoreRankingVoList.add(scoreRankingVo);
        return R.ok(scoreRankingVoList);
    }

    @ApiOperation("风险统计")
    @GetMapping("riskStatistics")
    public R<ChartVo> riskStatistics(RiskStatisticsDto riskStatisticsDto) {
        if (riskStatisticsDto.getLib() == null || riskStatisticsDto.getNumber() == null) {
            ChartVo chartVo = new ChartVo();
            chartVo.setXData(new ArrayList<>());
            chartVo.setValeus(new ArrayList<>());
            return R.ok(chartVo);
        }
        ChartVo chartVo=roofHazardService.riskStatistics(riskStatisticsDto);
        return R.ok(chartVo);
    }

}